<?php
/*
author name: shravani
created date: 15-07-2013
*/

error_reporting( E_ERROR | E_USER_ERROR );

$totalRecCount = 0;
$arrlength = 0;
$duplicateCount = 0;

$xml=simplexml_load_file($_GET['name']);
$totalRecCount = count($xml->record); //get the total num of records in xml

$isName = FALSE;
$isEmail = FALSE;
$isAddress = FALSE;
$isCity = FALSE;
$isTelephone = FALSE;

if (isset($_GET['is_Name']))
$isName = TRUE;

if (isset($_GET['is_Address']))
$isAddress = TRUE;

if (isset($_GET['is_Email']))
$isEmail = TRUE;

if (isset($_GET['is_City']))
$isCity = TRUE;

if (isset($_GET['is_Telephone']))
$isTelephone = TRUE;

$dataFilterKey = "";
$i = 0;

$strName = "";
$strAddress = "";
$strTelephone = "";
$strCity ="";
$strEmail ="";


foreach($xml->children() as $xml1)
{
	foreach($xml1->children() as $child)
  	{
		    if($child->getName() == "name")
			$strName = $child;
			if($child->getName() == "address")
			$strAddress = $child;
			if($child->getName() == "telephone")
			$strTelephone = $child;
			if($child->getName() == "email")
			$strEmail = $child;
			if($child->getName() == "city")
			$strCity = $child;		
  	}
	if ( $isName OR $isAddress OR $isTelephone OR $isEmail OR $isCity )
	{
			if($isName)
			$dataFilterKey = $dataFilterKey . $strName;
			if($isAddress)
			$dataFilterKey = $dataFilterKey . $strAddress;
			if($isTelephone)
			$dataFilterKey = $dataFilterKey . $strTelephone;
			if($isEmail)
			$dataFilterKey = $dataFilterKey . $strEmail;
			if($isCity)
			$dataFilterKey = $dataFilterKey . $strCity;
			
			
			$dataArray[$dataFilterKey]["name"] = $strName;
			$dataArray[$dataFilterKey]["address"] = $strAddress; 
			$dataArray[$dataFilterKey]["telephone"] = $strTelephone; 
			$dataArray[$dataFilterKey]["email"] = $strEmail; 
			$dataArray[$dataFilterKey]["city"] = $strCity; 
			$dataFilterKey = "";
	}else
	{
					
			$dataArray[$i]["name"] = $strName;
			$dataArray[$i]["address"] = $strAddress; 
			$dataArray[$i]["telephone"] = $strTelephone; 
			$dataArray[$i]["email"] = $strEmail; 
			$dataArray[$i]["city"] = $strCity; 
			$i++;
	}
	

	
}



	$arrlength=count($dataArray);
	$duplicateCount = $totalRecCount - $arrlength;
	
	echo $duplicateCount .";" . $arrlength;
	

?>